package com.atguigu.lease.admin.service.impl;

import com.atguigu.lease.model.dto.BrowserHistoryQueryDto;
import com.atguigu.lease.model.vo.BrowsingHistoryItemVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.lease.model.bean.BrowsingHistory;
import com.atguigu.lease.admin.service.BrowsingHistoryService;
import com.atguigu.lease.admin.mapper.BrowsingHistoryMapper;
import org.springframework.stereotype.Service;

/**
* @author 1
* @description 针对表【browsing_history(浏览历史)】的数据库操作Service实现
* @createDate 2025-09-22 17:18:51
*/
@Service
public class BrowsingHistoryServiceImpl extends ServiceImpl<BrowsingHistoryMapper, BrowsingHistory>
    implements BrowsingHistoryService{

    @Override
    public Page<BrowsingHistoryItemVo> getBrowsingHistoryItemVoPage(BrowserHistoryQueryDto queryDto) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq(queryDto.getUserId()!=null , "t1.user_id" , queryDto.getUserId());
        queryWrapper.ge(queryDto.getBegin()!=null , "t1.browse_time" , queryDto.getBegin() );
        queryWrapper.le(queryDto.getEnd()!=null , "t1.browse_time" , queryDto.getEnd() );
        queryWrapper.orderByDesc("t1.browse_time");
        return baseMapper.selectBrowsingHistoryItemVoPage(new Page(queryDto.getCurrent(), queryDto.getSize())
                , queryWrapper);
    }
}




